<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Cityanalysis,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@page import="sun.reflect.generics.tree.IntSignature"%>
<%@page import="com.ejoysoft.common.Format"%>
<%@ page import="java.util.List"%>
<%@ page import="com.ejoysoft.citygraph.*"%>
<%@page import="java.util.Random"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ include file="../include/jsp/head.jsp"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'regional_coverage.jsp' starting page</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="../css/main.css" rel="stylesheet" type="text/css" />
	<script language="JavaScript" src="../include/date/popc.js"></script>
	<script src="../include/js/list.js"></script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
  <% 
  	Cityanalysis task0 = null;
	Cityanalysis obj = new Cityanalysis(globa);

	//获取所有地市
	String where = "";
	List<String> listcity = obj.returnCity(where);	
	
	List<String> data = new ArrayList<String>();
	List<String> links = new ArrayList<String>();
	List<String> data1 = new ArrayList<String>();
	List<String> links1 = new ArrayList<String>();
	List<String> data2 = new ArrayList<String>();
	List<String> links2 = new ArrayList<String>();
	List<String> data3 = new ArrayList<String>();
	List<String> links3 = new ArrayList<String>();
	
	//分别对每个城市进行信息统计
	for(int i=0;i<listcity.size();i++){
		//***********************统计每个城市热点完成测试所占比例*****************************//
		///////////////统计每个城市的热点总数，记为count1///////////////
		where = "where strcity= '"+listcity.get(i)+"'";
		int count1 = obj.returnHpcount(where);		
		//////////////统计每个城市已测试的热点数目,记为count2///////////////
		where = "";
		int count2 = obj.returntestedHpcount(where,listcity.get(i));
		float rate_hotpot = 0;
		System.out.println(listcity.get(i)+"总热点数为："+count1+",已测热点数为:"+count2);
		if(count1!=0){
			rate_hotpot = (float)count2/(float)count1;
		}
		data.add(Double.toString(rate_hotpot));
		links.add("");
		
		//***********************统计每个城市AP完成测试所占比例******************************//
		///////////////统计每个城市的AP总数，记为count1///////////////
		where = "where strcity= '"+listcity.get(i)+"'";
		count1 = obj.returnApcount(where);		
		//////////////统计每个城市已测试的热点数目,记为count2///////////////
		where = "";
		count2 = obj.returntestedApcount(where,listcity.get(i));
		System.out.println(listcity.get(i)+"总AP数为："+count1+",已测AP数为:"+count2);	
		float rate_ap = 0;
		if(count1!=0){
			rate_ap = (float)count2/(float)count1;
		}
		data1.add(Double.toString(rate_ap));
		links1.add("");	
		
		//***********************统计每个城市任务完成测试所占比例***************************//
		///////////////统计每个城市的下发任务总数，记为count1///////////////
		where = listcity.get(i);
		count1 = obj.returnTaskcount(where);
		//////////////统计每个城市已测试的热点数目,记为count2///////////////
		where = "";
		count2 = obj.returntestedTaskcount(where,listcity.get(i));
		System.out.println(listcity.get(i)+"总任务数为："+count1+",已测任务数为:"+count2);
		float rate_task = 0;
		if(count1!=0){
			rate_task = (float)count2/(float)count1;
		}
		data2.add(Double.toString(rate_task));
		links2.add("");	
		
		//***********************统计每个城市人员完成测试所占比例**************************//
		///////////////统计每个城市的人员总数，记为count1///////////////
		where = listcity.get(i);
		count1 = obj.returnMancount(where);
		//////////////统计每个城市完成测试人员的数目,记为count2///////////////
		where = "";
		count2 = obj.returntestedMancount(where,listcity.get(i));
		System.out.println(listcity.get(i)+"总测试人员数为："+count1+",已测测试人员数为:"+count2);
		float rate_maintainer = 0;
		if(count1!=0){
			rate_maintainer = (float)count2/(float)count1;
		}
		data3.add(Double.toString(rate_maintainer));
		links3.add("");		
	}

	Graph g = new Graph();
	//坐标标题
	g.title("测试结果占比呈现", "{font-size: 25px;}");
	
	g.set_data(data);
	g.set_data(data1);
	g.set_data(data2);
	g.set_data(data3);
	
	g.line(2, "0x9933CC", "热点占比", 10, 2);
	g.line_hollow("2", "4", "0x80a033", "AP占比", "10");
	g.line_hollow("2", "4", "0xff0000", "任务占比", "10");
	g.line_hollow("2", "4", "0x00ff00", "人员占比", "10");

	g.set_links(links);
	
	// label each point with its value
	List<String> labels = new ArrayList<String>();
	for(int i=0;i<listcity.size();i++){
		labels.add(listcity.get(i));
	}
	
	g.set_x_labels(labels);
	g.set_x_label_style("20", "#FF0000", 0,1, "");
	g.set_x_legend("地市热点统计图", -1, "#736AFF");
	
	// set the Y max
	g.set_y_max(1);
	// label every 20 (0,20,40,60)
	g.y_label_steps(1);
%>
<%=g.render()%>
  </body>
</html>
<%@ include file="../include/jsp/footer.jsp"%>
